package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.service.MemberService;
import com.itheima.service.MenuService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhouwei
 * @date 2020-01-16 15:16
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Reference
    private MenuService menuService;

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        PageResult menuList;
        try {
            String queryString = queryPageBean.getQueryString();
            if(queryString!=null&&queryString.length()>0){
                String replace = queryString.replace(" ", "");
                queryPageBean.setQueryString(replace);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        menuList= menuService.findPage(queryPageBean);
        return menuList;
    }
}
